package com.yycx.module.bus.provider.controller.hy;

import com.yycx.common.utils.DateUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.yycx.common.mybatis.model.*;

import java.util.Map;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RestController;
import com.yycx.common.springmvc.base.BaseController;
import com.yycx.module.bus.client.entity.hy.BusBankStatement;
import com.yycx.module.bus.provider.service.hy.BusBankStatementService;
import org.springframework.web.multipart.MultipartFile;


/**
 * 银行流水控制器
 *
 * @author flyme
 * @date 2023-11-05
 */
@RestController
@RequestMapping("/bus/bbs/")
public class BusBankStatementController extends BaseController<BusBankStatementService, BusBankStatement> {

    @ApiOperation(value = "银行流水-分页列表", notes = "银行流水分页列表")
    @GetMapping(value = "page")
    public ResultBody pageList(@RequestParam(required = false) Map params) {
        return bizService.pageList(params);
    }

    @ApiOperation(value = "银行流水-列表", notes = "银行流水列表")
    @GetMapping(value = "list")
    public ResultBody list(@RequestParam(required = false) Map params) {
        return bizService.listEntityMap(params);
    }

    @ApiOperation(value = "银行流水-添加", notes = "添加银行流水")
    @PostMapping(value = "save")
    public ResultBody save(@RequestParam(required = false) Map params) {
        return bizService.add(params);
    }

    @ApiOperation(value = "银行流水-更新", notes = "更新银行流水")
    @PostMapping(value = "update")
    public ResultBody update(@RequestParam(required = false) Map params) {
        return bizService.edit(params);
    }

    @ApiOperation(value = "银行流水-删除", notes = "删除银行流水")
    @PostMapping(value = "remove")
    public ResultBody remove(@RequestParam(required = false) Map params) {
        return bizService.delete(params);
    }


    @ApiOperation(value = "银行流水-详情", notes = "银行流水详情")
    @GetMapping(value = "get")
    public ResultBody get(@RequestParam(required = false) Map params) {
        return bizService.get(params);
    }

    @ApiOperation(value = "银行流水-导入数据", notes = "银行流水-导入数据")
    @PostMapping(value = "importData")
    public ResultBody importData(@RequestParam(required = false) Map params, @RequestParam("file") MultipartFile file) {
        ResultBody resultBody = bizService.importData(file, params);
        return resultBody;
    }

    @ApiOperation(value = "设置认款状态", notes = "设置认款状态")
    @PostMapping(value = "setAmountState")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "ids", required = true, value = "主键", paramType = "form"),
        @ApiImplicitParam(name = "amountState", required = true, value = "状态值", paramType = "form")
    })
    public ResultBody setAmountState(@RequestParam(required = false) Map map, @RequestParam(value = "amountState") Integer amountState) {
        return bizService.setState(map, "amountState", amountState);
    }


    @PostMapping(value = "exportList")
    public void exportList(@RequestParam(required = false) Map params, HttpServletRequest request, HttpServletResponse response) {
        long date= DateUtils.getCurrentTimestamp();
        bizService.export(params, request, response, "银行流水-"+date, "银行流水", "hyBankStatementPageListHandler");
    }
}
